how to derive the cos(3x) formula using complex numbers